#include "GetValue.h"
#include <QDir>
#include <QBuffer>
#include <qDebug>
GetValue::GetValue(QObject *parent)
	: QThread(parent)
{
	Run = false;
}

GetValue::~GetValue()
{
}

void GetValue::run()
{
	while (Run)
	{
		if (sharrmemory->nativeKey() != "")
		{
			if (sharrmemory->attach())
			{
				if (sharrmemory->data() != nullptr)
				{
					QBuffer buffer;
					sharrmemory->lock();
					buffer.setData((char*)sharrmemory->constData(), sharrmemory->size());
					buffer.open(QBuffer::ReadOnly);
					sharrmemory->unlock();
					QByteArray bufferB(buffer.data());
					QString str = QString::fromUtf8(bufferB);
					if (Buffer != str)
					{
						qDebug() << str;
						Buffer = str;
						emit SeedLog(str);
					}
					sharrmemory->detach();
				}
			}
		}
	}
}
